Archive for the ‘quick tips’ Category

Re-enabling desktop effects in Windows 7

Saturday, November 7th, 2009

Every once in a while, Windows 7’s Desktop Window Manager (DWM) spontaneously goes funky on me and loses its effects (transparency, blurring, shadows).

When this happens, you can get your effects back by going to Services and restarting the “Desktop Window Manager Session Manager” service, or by going to an Administrative command prompt and running:

net stop uxsms
net start uxsms

IE and Chrome

Thursday, September 17th, 2009

IE7 (2006) introduced Protected Mode, which runs browser tabs in separate, sandboxed processes to isolate tabs from each other and from the OS, communicating with central Broker processes that remain privileged and provide system services. Chrome’s architecture was designed similarly.

IE7’s Protected Mode uses Vista’s Mandatory Integrity Control, which prevents processes from modifying any files, allowing them to write only to locations marked as low, such as Temporary Internet Files. Files touched by processes are marked with their integrity level. Integrity Levels correspond to Internet Zones. Chrome on Vista also leverages MIC.

IE8 introduced InPrivate, among a bevy of other features. InPrivate is similar to Incognito browsing in Chrome.

Application-based packet filtering on Linux

Monday, September 14th, 2009

iptables can’t filter on process ID or any other “direct” application identifier, which means you can’t say things like, “Allow only Firefox to send/receive any packets.” However, it can filter on user/group ID, allowing you to do user-based packet filtering, so that you can at least restrict applications if you run them as a certain uid/gid. The owner module (xt_owner) matches the owner of the socket (man iptables for more details).

# iptables -m owner --help
iptables v1.4.4
[...]
owner match options:
[!] --uid-owner userid[-userid]      Match local UID
[!] --gid-owner groupid[-groupid]    Match local GID
[!] --socket-exists                  Match if socket exists

Of course, this all applies only to local sockets; if this system is serving as a router for other hosts, then you don’t have the uid/gid information for their sockets (if their OS even has those notions).

When you release shift too early

Tuesday, February 3rd, 2009
$ diff /tmp/list.txt ~/Desktop/list.txt
$ rm !!;1
rm: cannot remove `diff': No such file or directory
bash: 1: command not found

The semi-colon should’ve been a colon, which selects just word 1 from the previous line. Instead, I deleted everything. Of course that’s what I intended to do, you piece of crap.

I usually use trash-cli and don’t bother deleting most files in /tmp. duplicity helped me get my files back, thankfully.

While on this: freedesktop.org’s trash specification leaves a few things to be desired:

  • Consistent support for trashing on mounts besides the one containing your home directory.
  • Automatic erasing of old files on space depletion.

C trigraphs. WTF.

Tuesday, January 13th, 2009

I added a “loud” but seemingly innocuous print statement to debug a C++ program:

cout << "WAITING!?!?!?!??!" << endl;

On compilation, I got:

$ g++ -Wall -c -o main.o main.cc
In file included from main.lzz:12,
                 from main.cc:4:
/opt/armed/include/commons/st/st.h:229:35: 
warning: trigraph ??! ignored, use -trigraphs to enable

Turns out I used just the right combo of ?? and ! in my program. I had run into C trigraphs (gcc documentation).

Python default parameters

Wednesday, November 5th, 2008

I was recently bitten by this: “Default parameter values are evaluated when the function definition is executed.” Demo:

def mklist():
print 'making list'
return []

def f(x=[]):
x.append(3)
print x

print 'start'
f()
f()

The output:

making list
start
[3]
[3, 3]

Annoyingly, the above page from the language reference acknowledges that “This is generally not what was intended,” without justifying the status quo.

Wacom for X41 Tablet

Friday, October 24th, 2008

The Wacom tablet PC driver for Windows works for the X41 tablet PC. With this installed, applications that support Wacom devices rather than Microsoft Ink, such as Gimp, can leverage stylus features, including pressure sensitivity and high/static sample rates for smooth drawing.

sql.mit.edu backups

Tuesday, May 6th, 2008

The sql.mit.edu service performs nightly mysqldumps to /mit/sql/backup/. This could have spared me some grief when I wiped out my database.

Ubuntu 8.04 upgrade success

Saturday, May 3rd, 2008

apt-get install -f got me out of the dependency failure tarpit that was killing my attempts to apt-get install packages and to dpkg --configure -a. Another thing to try would’ve been apt-get clean -f. A subsequent apt-get dist-upgrade worked (took under 3 minutes).

FreeBSD CPU affinity

Friday, May 2nd, 2008

FreeBSD doesn’t support (userland) access to process/thread CPU affinity.